<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则表达式中的重复匹配</title>
</head>
<body>
    <script>
        let hd = "hdddd";

        // ?匹配0个或1个,只影响符号的前一个字符
        let reg1 = /hd?/;
        console.log(hd.match(reg1));

        // *匹配0个到多个,只影响符号的前一个字符
        let reg2 = /hd*/;
        console.log(hd.match(reg2));

        // +匹配1个到多个,只影响符号的前一个字符
        let reg3 = /hd+/;
        console.log(hd.match(reg3));

        // {1,3}匹配1个到3个,只影响符号的前一个字符
        let reg4 = /hd{1,3}/;
        console.log(hd.match(reg4));

        // {0,}匹配0个到多个,只影响符号的前一个字符
        let reg5 = /hd{0,}/;
        console.log(hd.match(reg5));

        // {1,}匹配1个到多个,只影响符号的前一个字符
        let reg6 = /hd{1,}/;
        console.log(hd.match(reg6));
    </script>
</body>
</html>